type userType = {
    name:string,
    isLogin:boolean,
    keys:string[]
}

const user:userType = {
    name:"houdunren",
    isLogin:true,
    keys:['storage']
}

const AccessDecoratorFactory = (keys:string[]):MethodDecorator => {
    return (target:Object, propertyKey:string | symbol,descriptor:PropertyDescriptor) => {
        const valid = () => {
            return keys.every(key => user.keys.includes(key))
        }
        descriptor.value = () => {
            if(user.isLogin == true && valid()) {
                alert("验证通过");
            }else{
                alert("验证失败");
            }
        }
    }
}

class Article{
    @AccessDecoratorFactory(['storage','manager'])
    storage(){
        console.log('保存文章');
    }
}

new Article().storage();